﻿using AutoMapper;

using NTQOnlineExam.Services.EntityFW.Entity;
using NTQOnlineExam.Services.Models;

namespace NTQOnlineExam.App_Start
{
    public class ObjectMapper
    {
        private static bool _mapped;

        public static void RegisterMapper()
        {
            if (!_mapped)
            {
                Mapper.CreateMap<Term, TermDTO>()
                    .ForMember("IsExpired", opt => opt.Ignore())
                    .ForMember("ExpiredDate", opt => opt.Ignore())
                    .ForMember("IsPaid", opt => opt.Ignore());
                Mapper.CreateMap<Section, SectionDTO>()
                    .ForMember("TotalQuestion", opt => opt.Ignore());
                Mapper.CreateMap<Services.EntityFW.Entity.UserProfile, UserProfileDTO>();
                Mapper.CreateMap<Services.EntityFW.Entity.Portfolio, PortfolioDTO>()
                    .ForMember("ExpiredDateDisplay", opt => opt.Ignore())
                    .ForMember("OrderDateDisplay", opt => opt.Ignore())
                    .ForMember("IsTermPublished", opt => opt.Ignore());
                Mapper.CreateMap<Order, OrderDTO>()
                        .ForMember("FirstName", opt => opt.Ignore())
                        .ForMember("LastName", opt => opt.Ignore())
                        .ForMember("FullName", opt => opt.Ignore())
                        .ForMember("CreationDateDisplay", opt => opt.Ignore())
                        .ForMember("SubTotalDisplay", opt => opt.Ignore())
                        .ForMember("StatusDescription", opt => opt.Ignore());
                Mapper.CreateMap<OrderDetail, OrderDetailDTO>();
                Mapper.CreateMap<Year, YearDTO>();
                _mapped = true;
            }
        }
    }
}